package com.ying.rabbitmqspringbootproducer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: ConfirmConfig
 * Package: com.ying.rabbitmqspringbootproducer.config
 * Description:
 *
 * @Author 刘英杰
 * @Create 2025/5/29 16:43
 * @Version 1.0
 */

@Configuration
public class ConfirmConfig {
    public static final String EXCHANGE_CONFIRM_NANE = "confirmExchange";
    public static final String QUEUE_CONFIRM_NANE = "confirmQueue";

    //定义交换机
    @Bean
    public Exchange confirmExchange() {
        return ExchangeBuilder.directExchange(EXCHANGE_CONFIRM_NANE).durable(true).build();
    }

    //定义队列
    @Bean
    public Queue confirmQueue() {
        return QueueBuilder.durable(QUEUE_CONFIRM_NANE).build();
    }

    //绑定队列到交换机
    @Bean
    public Binding bindingConfirmQueue(Exchange confirmExchange,Queue confirmQueue) {
        return BindingBuilder.bind(confirmQueue).to(confirmExchange).with("info").noargs();
    }

}
